using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using yq.IBase;
using yq.Dictionary;
using yq.Basis;
using yq.Model.Logic;
using System.Collections;
using Db;
using System.Data.Common;

namespace yq.Model.Base
{
    ///<summary>
    /// File_List - 文件信息 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IFileList<T> : ModelBase<FileList> where T : FileList, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.FileinfoId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return FileinfoId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy)
        {
            this.FileinfoId = dy.FileinfoId;
            this.UserId = dy.UserId;
            this.SuperiorId = dy.SuperiorId;
            this.Ttile = dy.Ttile;
            this.Type = dy.Type;
            this.Path = dy.Path;
            this.IsHide = dy.IsHide;
            this.Status = dy.Status;
            this.IsPrivate = dy.IsPrivate;
            this.IsCheckOut = dy.IsCheckOut;
            this.CheckUserId = dy.CheckUserId;
            this.CheckTime = dy.CheckTime;
            this.SubmitTime = dy.SubmitTime;
            this.VerId = dy.VerId;
            this.Version = dy.Version;
        }

        #region 定义属性


        /// <summary>
        /// 文件信息ID
        /// </summary>
        private String _FileinfoId = "";

        /// <summary>
        /// 文件信息ID
        /// </summary>
        public String FileinfoId
        {
            get
            {
                return (this._FileinfoId);
            }

            set
            {
                _FileinfoId = value;
            }
        }


        /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";

        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get
            {
                return (this._UserId);
            }

            set
            {
                _UserId = value;
            }
        }


        /// <summary>
        /// 上级文件Id
        /// </summary>
        private String _SuperiorId = "";

        /// <summary>
        /// 上级文件Id
        /// </summary>
        public String SuperiorId
        {
            get
            {
                return (this._SuperiorId);
            }

            set
            {
                _SuperiorId = value;
            }
        }


        /// <summary>
        /// 名称
        /// </summary>
        private String _Ttile = "";

        /// <summary>
        /// 名称
        /// </summary>
        public String Ttile
        {
            get
            {
                return (this._Ttile);
            }

            set
            {
                _Ttile = value;
            }
        }


        /// <summary>
        /// 类型
        /// </summary>
        private int _Type = -1;

        /// <summary>
        /// 类型
        /// </summary>
        public yq.Enums.FileList.Type Type
        {
            get
            {
                return (yq.Enums.FileList.Type)this._Type;
            }

            set
            {
                _Type = value.GetHashCode();
            }
        }


        /// <summary>
        /// 路径
        /// </summary>
        private String _Path = "";

        /// <summary>
        /// 路径
        /// </summary>
        public String Path
        {
            get
            {
                return (this._Path);
            }

            set
            {
                _Path = value;
            }
        }


        /// <summary>
        /// 是否隐藏
        /// </summary>
        private int _IsHide = -1;

        /// <summary>
        /// 是否隐藏
        /// </summary>
        public yq.Enums.BooleanType IsHide
        {
            get
            {
                return (yq.Enums.BooleanType)_IsHide;
            }

            set
            {
                _IsHide = value.GetHashCode();
            }
        }


        /// <summary>
        /// 状态
        /// </summary>
        private int _Status = -1;

        /// <summary>
        /// 状态
        /// </summary>
        public yq.Enums.FileList.Status Status
        {
            get
            {
                return (yq.Enums.FileList.Status)this._Status;
            }

            set
            {
                _Status = value.GetHashCode();
            }
        }


        /// <summary>
        /// 是否私用
        /// </summary>
        private int _IsPrivate = -1;

        /// <summary>
        /// 是否私用
        /// </summary>
        public yq.Enums.BooleanType IsPrivate
        {
            get
            {
                return (yq.Enums.BooleanType)_IsPrivate;
            }

            set
            {
                _IsPrivate = value.GetHashCode();
            }
        }


        /// <summary>
        /// 是否被签出
        /// </summary>
        private int _IsCheckOut = -1;

        /// <summary>
        /// 是否被签出
        /// </summary>
        public yq.Enums.BooleanType IsCheckOut
        {
            get
            {
                return (yq.Enums.BooleanType)_IsCheckOut;
            }

            set
            {
                _IsCheckOut = value.GetHashCode();
            }
        }


        /// <summary>
        /// 签出人
        /// </summary>
        private String _CheckUserId = "";

        /// <summary>
        /// 签出人
        /// </summary>
        public String CheckUserId
        {
            get
            {
                return (this._CheckUserId);
            }

            set
            {
                _CheckUserId = value;
            }
        }


        /// <summary>
        /// 签出时间
        /// </summary>
        private DateTime _CheckTime = DateTime.MinValue;

        /// <summary>
        /// 签出时间
        /// </summary>
        public DateTime CheckTime
        {
            get
            {
                return (this._CheckTime);
            }

            set
            {
                _CheckTime = value;
            }
        }


        /// <summary>
        /// 创建时间
        /// </summary>
        private DateTime _SubmitTime = DateTime.MinValue;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime SubmitTime
        {
            get
            {
                return (this._SubmitTime);
            }

            set
            {
                _SubmitTime = value;
            }
        }


        /// <summary>
        /// 最新版本ID
        /// </summary>
        private String _VerId = "";

        /// <summary>
        /// 最新版本ID
        /// </summary>
        public String VerId
        {
            get
            {
                return (this._VerId);
            }

            set
            {
                _VerId = value;
            }
        }


        #endregion 定义属性

        protected internal override void SetValue(FileList info, DataRow row)
        {
            if (row == null)
            {
                info.IsLoad = false;
            }
            else
            {
                info.IsLoad = true;

                if (row["FileinfoId"] != DBNull.Value)
                {
                    info.FileinfoId = row["FileinfoId"].ToString();
                }


                if (row["UserId"] != DBNull.Value)
                {
                    info.UserId = row["UserId"].ToString();
                }


                if (row["SuperiorId"] != DBNull.Value)
                {
                    info.SuperiorId = row["SuperiorId"].ToString();
                }


                if (row["Ttile"] != DBNull.Value)
                {
                    info.Ttile = row["Ttile"].ToString();
                }


                if (row["Type"] != DBNull.Value)
                {
                    info.Type = (yq.Enums.FileList.Type)(row["Type"]);
                }


                if (row["Path"] != DBNull.Value)
                {
                    info.Path = row["Path"].ToString();
                }


                if (row["IsHide"] != DBNull.Value)
                {
                    info.IsHide = (yq.Enums.BooleanType)(row["IsHide"]);
                }


                if (row["Status"] != DBNull.Value)
                {
                    info.Status = (yq.Enums.FileList.Status)(row["Status"]);
                }


                if (row["IsPrivate"] != DBNull.Value)
                {
                    info.IsPrivate = (yq.Enums.BooleanType)(row["IsPrivate"]);
                }


                if (row["IsCheckOut"] != DBNull.Value)
                {
                    info.IsCheckOut = (yq.Enums.BooleanType)(row["IsCheckOut"]);
                }


                if (row["CheckUserId"] != DBNull.Value)
                {
                    info.CheckUserId = row["CheckUserId"].ToString();
                }


                if (row["CheckTime"] != DBNull.Value)
                {
                    info.CheckTime = Convert.ToDateTime(row["CheckTime"]);
                }


                if (row["SubmitTime"] != DBNull.Value)
                {
                    info.SubmitTime = Convert.ToDateTime(row["SubmitTime"]);
                }


                if (row["VerId"] != DBNull.Value)
                {
                    info.VerId = row["VerId"].ToString();
                }


                if (row["Version"] != DBNull.Value)
                {
                    info.Version = row["Version"].ToString();
                }

            }

        }

        protected internal override void GetDbParameters(DbCommand comm, FileList info, DbHelper cn)
        {

            cn.AddInParameter(comm, "@FileinfoId", DbType.String, ParameterTool.GetObj(info._FileinfoId));


            cn.AddInParameter(comm, "@UserId", DbType.String, ParameterTool.GetObj(info._UserId));


            cn.AddInParameter(comm, "@SuperiorId", DbType.String, ParameterTool.GetObj(info._SuperiorId));


            cn.AddInParameter(comm, "@Ttile", DbType.String, ParameterTool.GetObj(info._Ttile));


            cn.AddInParameter(comm, "@Type", DbType.Int32, ParameterTool.GetObj(info._Type));


            cn.AddInParameter(comm, "@Path", DbType.String, ParameterTool.GetObj(info._Path));


            cn.AddInParameter(comm, "@IsHide", DbType.Int32, ParameterTool.GetObj(info._IsHide));


            cn.AddInParameter(comm, "@Status", DbType.Int32, ParameterTool.GetObj(info._Status));


            cn.AddInParameter(comm, "@IsPrivate", DbType.Int32, ParameterTool.GetObj(info._IsPrivate));


            cn.AddInParameter(comm, "@IsCheckOut", DbType.Int32, ParameterTool.GetObj(info._IsCheckOut));


            cn.AddInParameter(comm, "@CheckUserId", DbType.String, ParameterTool.GetObj(info._CheckUserId));


            cn.AddInParameter(comm, "@CheckTime", DbType.DateTime, ParameterTool.GetObj(info._CheckTime));


            cn.AddInParameter(comm, "@SubmitTime", DbType.DateTime, ParameterTool.GetObj(info._SubmitTime));


            cn.AddInParameter(comm, "@VerId", DbType.String, ParameterTool.GetObj(info._VerId));


            cn.AddInParameter(comm, "@Version", DbType.String, Guid.NewGuid().ToString());


            cn.AddInParameter(comm, "@_versionOdl", DbType.String, info._Version);

        }

    }
}